using System;
using System.Collections.Generic;
using Universe.Farm.Service;
using Universe.Farm.Service.Mesages;

namespace Universe.Farm.RemotingService
{
    public class RemotingFarmService: MarshalByRefObject, IFarmService
    {
        private ConfigurationContainer _config;
        
        public RemotingFarmService()
        {
        }

        public RemotingFarmService(ConfigurationContainer config)
        {
            _config = config;
        }

        public override object InitializeLifetimeService()
        {
            return null;
        }

        public IList<HealthInfo> GetServices(ServicesScope scope)
        {
            IHealthCollection state = _config.ResolveRequired<IHealthCollection>();
            return state.GetServices(scope);
        }

        public void LookupServices(ServicesScope scope)
        {
            ILookupRequestSender sender = _config.ResolveRequired<ILookupRequestSender>();
            sender.SendLookupMessage(scope);
        }
    }
}